<?php
	// PHP抽奖
	function get_rand($proArr) {   
    $result = array();
    foreach ($proArr as $key => $val) { 
        $arr[$key] = $val['v']; 
    } 
    // 概率数组的总概率  
    $proSum = array_sum($arr);        
    asort($arr);
    // 概率数组循环   
    foreach ($arr as $k => $v) {   
        $randNum = mt_rand(1, $proSum);   
        if ($randNum <= $v) {   
            $result = $proArr[$k];   
            break;   
        } else {   
            $proSum -= $v;   
        }         
    }     
    return $result;
 }
 $arr = array(   
    array('id'=>1,'prize'=>'特等奖','v'=>1),
    array('id'=>2,'prize'=>'一等奖','v'=>2),
    array('id'=>3,'prize'=>'二等奖','v'=>3),
    array('id'=>4,'prize'=>'三等奖','v'=>30),
    array('id'=>5,'prize'=>'四等奖','v'=>30),
    array('id'=>6,'prize'=>'没中奖','v'=>34)
);
$prize = get_rand($arr);
if($prize['id'] == 6){
	echo '很遗憾,您本次没有中奖,请关注下次活动';
}
else{
	echo '恭喜您获得'.$prize['prize'];
}